package com.sunxboy.platform.option;

import java.util.Map;

public class RuntimeSelector {
    private String getOperatingSystem() {
        final String osName = System.getProperty("os.name").toLowerCase();

        if (osName.startsWith("windows")) {
            return "WINDOWS";
        }
        else if (osName.startsWith("linux")) {
            return "LINUX";
        }
        else if (osName.startsWith("solaris")) {
            return "SOLARIS";
        }
        else {
            throw new UnsupportedOperationException("Unknown OS detected: " + osName);
        }
    }

    public String getOsConfiguraton(Map<String, String> configMap) {
        return configMap.get(getOperatingSystem());
    }

    public String getRuntimeConfiguration(Map<String, String> allConfigMap, String specifiedKey) {
        return allConfigMap.get(specifiedKey);
    }
}
